import 'package:common/common.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:main_plugin/main_page.dart';
import 'package:package_info/package_info.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';


class MakerApp extends StatefulWidget {
  @override
  _MakerAppState createState() => _MakerAppState();
}

class _MakerAppState extends State<MakerApp> {
  PackageInfo packageInfo;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<LocaleBloc, Locale>(
      cubit: BlocProvider.of(context),
      builder: (BuildContext context, Locale localeState) {
        return ScreenUtilInit(
            designSize: Size(1920, 1080),
            builder: () {
              return MaterialApp(
                //onGenerateRoute：GlobalRouterManager.router.generator,
                theme: ThemeData(
                  primarySwatch: Colors.blue,
                  primaryColor: TColor.primeColor,
                  dividerColor: TColor.dividerGray,
                  visualDensity: VisualDensity.adaptivePlatformDensity,
                  highlightColor: Colors.transparent,
                  splashColor: Colors.transparent,
                  buttonTheme: ButtonThemeData(),
                ),
                localizationsDelegates: ModuleManager().localizationDelegates,
                locale: localeState,
                home: MainPage(),
                builder: (context, widget) {
                  return MediaQuery(
                    //设置文字大小不随系统设置改变
                    data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
                    child: widget,
                  );
                },
              );
            });
      },
    );
  }
}
